<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>垂直居中一个浮动元素</title>
  <style>
    .outer {
      position: relative;
      height: 200px;
    }

    .float {
      float: left;
      height: 100px;
      line-height: 100px;
      top: 50%;
      margin-top:-50px;
      position: absolute;
    }
  </style>
</head>
<body>
<div class="outer">
  <div class="float">垂直居中一个浮动元素</div>
</div>
</body>
</html>
